<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    function sum(a, b) {
      let args = Array.from(arguments);
      console.log(args.reduce((sum, cur) => sum + cur));
    }
    sum(1, 2);

    function sum(a, b) {
        // 在函数作用域中使用拓展运算符
      let args = [...arguments];
      console.log(args.reduce((sum, cur) => sum + cur));
    }
    sum(1, 2);

    function sum(...args) {
        // 在形参中使用拓展运算符
      console.log(args.reduce((sum, cur) => sum + cur));
    }
    sum(1, 2);
  </script>
</html>
